package com.example.demo.controller;

import com.example.demo.VO.Result;
import com.example.demo.entity.Questiontype;
import com.example.demo.service.QuestiontypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * (Questiontype)表控制层
 *
 * @author hjl
 * @since 2020-11-30 19:33:04
 */
@RestController
@RequestMapping("questiontype")
@Api(value="题目类型controller",tags={"题目类型操作接口"})
public class QuestiontypeController {
    /**
     * 服务对象
     */
    @Resource
    private QuestiontypeService questiontypeService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Questiontype selectOne(Integer id) {
        return this.questiontypeService.queryById(id);
    }

    @ApiOperation(value="添加题目类型",tags={"添加题目类型"},notes="注意问题点")
    @GetMapping("addQuestionType")
    public Result addQuestionType(Questiontype questiontype){
        questiontypeService.insert(questiontype);
        return Result.success(questiontypeService.queryByExample(questiontype));
    }

    @ApiOperation(value="删除题目类型",tags={"删除题目类型"},notes="注意问题点")
    @GetMapping("deleteQuestionType")
    public Result deleteQuestionType(Integer questionId){
        questiontypeService.deleteById(questionId);
        return Result.success();
    }

}